<{include file="Public/head.tpl"}>

<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap-table/1.8.1/bootstrap-table.min.css">

<{include file="Public/header.tpl"}>
<{include file="Public/siderbar.tpl"}>
<{include file="Public/contentheader.tpl"}>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <a class="btn btn-primary btn-flat" href="/admin/power/add">新增权限</a>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table data-toggle="table"
                               data-url="/admin/power/list" 
                               data-method="post"
                               data-content-type="application/x-www-form-urlencoded"
                               data-side-pagination="server" 
                               data-pagination="true" 
                               data-search="true"
                               data-show-columns="true"
                               data-show-export="true"
                               data-show-refresh="true"
                               data-response-handler="responseHandler">
                            <thead>
                                <tr>
                                    <th data-field="id" data-align="left">权限ID</th>
                                    <th data-field="title" data-align="left">权限名</th>
                                    <th data-field="contr_action" data-align="left">控制器/方法</th>
                                    <th data-field="parent_title" data-align="center">上级权限名</th>
                                    <th data-field="type" data-align="center">类型</th>
                                    <th data-field="status" data-align="center">状态</th>
                                    <th data-field="operate" data-align="center">操作</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<{include file="Public/footer.tpl"}>

<!-- Tables -->
<script src="http://cdn.bootcss.com/bootstrap-table/1.8.1/bootstrap-table.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap-table/1.8.1/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap-table/1.8.1/extensions/export/bootstrap-table-export.min.js"></script>
<script src="/admin/plugins/tableexport/tableexport.js"></script>
<!-- page script -->
<script>
function responseHandler(res) {
    $.each(res.rows, function (i, row) {
        var edithtml = '<a class="fa fa-fw fa-edit" href="/admin/power/edit/id/' + row.id + '" title="编辑权限"></a>';
        if (row.status == 1) {
            row.status = '<span class="label label-success">启用</span>';
            row.operate = edithtml;// + disablehtml;
        }else{
            row.status = '<span class="label label-danger">禁用</span>';
            row.operate = edithtml;// + enablehtml;
        }
        
        if (!row.parent_title){
            row.parent_title = "无";
        }
        
        if (row.type == 1) {
            row.type = "权限+菜单";
        }else if (row.type == 2) {
            row.type = "仅权限";
        }else {
            row.type = "仅菜单";
        }
    });
    return res;
}
</script>
</body>
</html>